# 1. 修改现有值
person = {"name": "Alice", "age": 30}
person["age"] = 31  # 更新年龄
print(person)  # 输出：{'name': 'Alice', 'age': 31}

# 2. 添加新键值对
person["city"] = "New York"  # 添加新键值对
print(person)  # 输出：{'name': 'Alice', 'age': 31, 'city': 'New York'}

# 3. 批量更新（合并字典）
additional_info = {"hobbies": ["reading", "swimming"], "age": 32}
person.update(additional_info)  # 存在的键会被覆盖，新增的键会被添加
print(
    person
)  # 输出：{'name': 'Alice', 'age': 32, 'city': 'New York', 'hobbies': ['reading', 'swimming']}
